<template>
    <view class="g_content">
        <view class="dis_f_c_c">
            <u-tabs :list="tabList" :current="currentIndex" lineColor="#27AC2F" @click="handleTab"></u-tabs>
        </view>
        <view v-if="list.length>0">
            <view v-for="(item,index) in list" :key="index">
                <uni-card>
                    <view class="dis_f_r_c">
                        <u-tag v-if="item.ifCardReview==2" text="待审核" type="warning" size="mini"></u-tag>
                        <u-tag v-if="item.ifCardReview==3" text="审核通过" type="success" size="mini"></u-tag>
                        <u-tag v-if="item.ifCardReview==4" text="审核驳回" type="error" size="mini"></u-tag>
                    </view>
                    <u-divider></u-divider>
                    <view>身份：{{item.typeName}}</view>
                    <view>地区：{{item.city}}</view>
                    <view v-if="item.type==1">
                        <view>姓名：{{item.sfzXm}}</view>
                        <view>身份证号：{{item.sfzHm}}</view>
                        <view class="dis_f_l m_b_10">
                            <view>身份证人像面：</view>
                            <u-image :src="item.idCardUrl" width="300rpx" height="200rpx" @click="handlePriveImg(item.idCardUrl)"></u-image>
                        </view>
                        <view class="dis_f_l">
                            <view>身份证国徽面：</view>
                            <u-image :src="item.idCardNegativeUrl"  width="300rpx" height="200rpx" @click="handlePriveImg(item.idCardNegativeUrl)"></u-image>
                        </view>
                    </view>
                    <view v-else>
                        <view>企业名称：{{item.enterpriseName}}</view>
                        <view>联系方式：{{item.enterprisePhone}}</view>
                        <view class="dis_f_l">
                            <view>营业执照：</view>
                            <u-image :src="item.businessLicenseUrl"  width="300rpx" height="200rpx" @click="handlePriveImg(item.businessLicenseUrl)"></u-image>
                        </view>
                    </view>
                    <view class="c_red" v-if="item.ifCardReview==4">驳回原因：{{item.reasonsReview}} </view>
                    <u-divider></u-divider>
                    <view class="dis_f_r_c" v-if="currentIndex==0||currentIndex==2">
                        <view class="m_r_10">
                            <u-button type="error" shape="circle" size="mini" @click="handleShowReject(item)">驳回</u-button>
                        </view>
                        <view>
                            <u-button type="primary" shape="circle" size="mini" color="#27AC2F" @click="handlePass(item)">通过</u-button>
                        </view>
                    </view>
                </uni-card>
            </view>
        </view>
        <view class="m_t_100"  v-else>
            <s-empty ></s-empty>
        </view>

        <!-- 授权弹窗 -->
        <s-auth-modal />
        <u-modal :show="showExamine" title="实名审核" showCancelButton @cancel="showExamine=false" @confirm="handleReject">
            <u--form
                labelPosition="top"
                labelWidth="auto"
            >
                <u-form-item
                    label="驳回原因"
                    ref="item1"
                >
                    <u--textarea   v-model="dataReview.reasonsReview" placeholder="请输入驳回原因"></u--textarea >
                </u-form-item>
            </u--form>
        </u-modal>

    </view>
</template>
<script>
import {myMixins} from "@/mixins/myMixins";
import {getAreaListApi, getApprovalListApi, advertisingApi, putUserApi, becomeAgentApi} from "@/sheep/api";

export default {
    mixins: [myMixins],
    name: "mySend",
    data() {
        return {
            userId:'',
            tabList: [{name: '待审核'}, {name: '已通过'}, {name: '已驳回'},],
            currentIndex: 0,
            list: [],
            pattern: {
                color: '#7A7E83',
                backgroundColor: '#fff',
                selectedColor: '#27AC2F',
                buttonColor: '#27AC2F',
                iconColor: '#fff'
            },
            show:false,
            showExamine:false,
            queryData:{
                state:1
            },
            dataReview:{
                ifCardReview:4,
                reasonsReview:''
            }

        }
    },
    onShow() {
        this.updateData()
    },
    methods: {
        handlePriveImg(img){
            uni.previewImage({
                current: img,
                urls: [img]
            })
        },
        handleToDetail(item) {
            uni.navigateTo({
                url: '/pages/info/index?userId=' + item.userId
            })
        },
        getList() {
            this.queryObj.ifCardReview = this.currentIndex+2
            getApprovalListApi(this.queryObj).then(res => {
                this.list = this.list.concat(res.rows)
                this.total = res.total
                if (this.queryObj.pageNum * this.queryObj.pageSize < this.total) {
                    this.status = 'loadmore'
                } else {
                    this.status = 'nomore'
                }
                uni.stopPullDownRefresh()
            })
        },
        handleTab(e) {
            this.currentIndex = e.index
            this.updateData()
        },
        fabClick(){
            this.show=true
        },
        handleShowReject(item){
            this.dataReview.userId=item.userId
            this.showExamine=true
        },
        handlePass(item){
            uni.showModal({
                title: '提示',
                content: '确定通过吗？',
                success: (res) => {
                    if (!res.confirm){
                        return
                    }
                    putUserApi({userId:item.userId,ifCardReview:3}).then(res=>{
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        })
                        if (res.code==200){
                            this.showExamine=false
                            this.updateData()
                        }
                    })
                }
            })
        },
        handleReject(){
            if (!this.dataReview.reasonsReview){
                 uni.showToast({
                    title: '请输入驳回原因',
                    icon: 'none'
                })
                return
            }
            putUserApi(this.dataReview).then(res=>{
                uni.showToast({
                    title: res.msg,
                    icon: 'none'
                })
                if (res.code==200){
                    this.dataReview.reasonsReview=''
                    this.showExamine=false
                    this.updateData()
                }
            })
        }
    }
}
</script>

<style scoped lang="scss">
/deep/ .u-modal__content{
    display: unset!important;
}
</style>
